﻿/******************************************************************************
* File description: animationState_Practice.cpp
* Function: 打靶动画State，用于记录当前动画的状态，并（只记录目标位置，中间过渡位置由Controller计算）
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/

#include "animationState_Practice.h"

/** @brief 构造函数 */
AnimationState_Practice::AnimationState_Practice()
{
    reset();
}

/** @brief 重置动画状态至机器复位状态 */
void AnimationState_Practice::reset(){
    _barOperation.clear();
    _feedPortPosi = 0;
    _wheelAngle = 1;
    _bottleState = 0;
    _barPosi = 1;
    _pump1State = 0;
    _pump2State = 0;
    _blowTargetState = 0;
    _brakeState = 0;
    _absorbState = 0;
}

/** @brief 设置抱闸状态 0松开 1夹紧 */
void AnimationState_Practice::setBrakeState(int state){
    if(state == 0){
        _barOperation.push_back(UNLOCK);
    }else if(state == 1){
        _barOperation.push_back(LOCK);
    }
//    _brakeState = state;
}

/** @brief 设置转盘状态
 * @param direct 0朝左 1朝下  */
void AnimationState_Practice::turnWheel(int direct){
    if(direct == 0){
        _barOperation.push_back(WHEEL_TURN_LEFT);
    }else if(direct == 1){
        _barOperation.push_back(WHEEL_TURN_DOWN);
    }
//    _wheelAngle = direct;
}

/** @brief 设置上面那个泵的状态
 * @param state 0关 1开 -1异常 */
void AnimationState_Practice::setPump1State(int state){
    _pump1State = state;
}

/** @brief 设置下面那个泵的状态
 * @param state 0关 1开 -1异常  */
void AnimationState_Practice::setPump2State(int state){
    _pump2State = state;
}

/** @brief 设置氮气泵的状态
 * @param state 0关 1开 -1异常 */
void AnimationState_Practice::setPumpN2State(int state){
    _pumpN2State = state;
}

/** @brief 设置是否有靶材罐
 * @param state 0正常 -1不存在  */
void AnimationState_Practice::setBottleState(int state){
    _bottleState = state;
}

/** @brief 设置进料口的位置
 * @param posi 0在上面 1在下面
 */
void AnimationState_Practice::moveFeedPort(int posi){
    _feedPortPosi = posi;
}

/** @brief 设置左右滑竿的位置
 * @param posi 0在左面 1在右面 */
void AnimationState_Practice::moveBar(int posi){
    if(posi == 0){
        _barOperation.push_back(MOV_LEFT);
    }else if(posi == 1){
        _barOperation.push_back(MOV_RIGHT);
    }
//    _barPosi = posi;
}

/** @brief 设置传靶吹气的状态  */
void AnimationState_Practice::setBlowTargetState(int state){
    _blowTargetState = state;
}

/** @brief 设置吸取梭体状态 0关闭 1开启  */
void AnimationState_Practice::setAbsorbState(int state){
    _absorbState = state;
}

